﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IFRS.Web;
using IFRS.Models;
using IFRS.DataAccess.DAL;
using System.Data;
using IFRS_Global;
using System.Globalization;
using System.Threading;
using vsm.CustomControl;

public partial class IFRS_WIN31_GL_TR_3V : PageBase
{
    #region "---------- Events -----------"
    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
        if (!(Page.IsPostBack || Page.IsCallback))
        {                        
            this.ViewMenu();           
            if (Request.QueryString["id"] != null)
            {
                this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
            }
            this.SetControl();
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }    
    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN31_1S.aspx");
    }
    #endregion
    #region "---------- Methods -----------"        
    private void BindData(int ID)
    {
        List<GLAccountPosting> gLAccountPosting = new List<GLAccountPosting>();
        DataTable dt = new SPR_GLACCOUNTPOSTING().SEARCH_BYID(ID);
        if (dt.Rows.Count > 0)
        {

            ConvertHelper.ConvertDataTableToObject(dt, gLAccountPosting);                               

            #region 'Binding CODE Value'
            txtGL_ACCOUNT.Text = gLAccountPosting[0].GLAccount_CODE;
            txtGL_ADJ_INT_INC_PL.Text = gLAccountPosting[0].GL_ADJ_INT_INC_PL_CODE;
            txtGL_ADJ_FV_BS.Text = gLAccountPosting[0].GL_ADJ_FV_BS_CODE;
            txtGL_ADJ_INT_INC_ELCLS_PL.Text = gLAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_CODE;
            txtGL_ADJ_CST_BS.Text = gLAccountPosting[0].GL_ADJ_CST_BS_CODE;
            txtGL_REV_CST_PL.Text = gLAccountPosting[0].GL_REV_CST_PL_CODE;
            txtGL_ADJ_FEE_BS.Text = gLAccountPosting[0].GL_ADJ_FEE_BS_CODE;
            txtGL_REV_FEE_PL.Text = gLAccountPosting[0].GL_REV_FEE_PL_CODE;
            txtGL_SUBSEQ_ADJ_CST_BS.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_CODE;
            txtGL_SUBSEQ_ADJ_FEE_BS.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_CODE;
            txtGL_IMP_LOSS_PL.Text = gLAccountPosting[0].GL_IMP_LOSS_PL_CODE;
            txtGL_ALLW_BAD_DEBT_PL.Text = gLAccountPosting[0].GL_ALLW_BAD_DEBT_PL_CODE;
            txtGL_WOFF_ADJ_FV_BS.Text = gLAccountPosting[0].GL_WOFF_ADJ_FV_BS_CODE;
            txtGL_WOFF_ADJ_FEE_BS.Text = gLAccountPosting[0].GL_WOFF_ADJ_FEE_BS_CODE;
            txtGL_WOFF_ADJ_CST_BS.Text = gLAccountPosting[0].GL_WOFF_ADJ_CST_BS_CODE;
            txtGL_DAY1_FV_LOSS_PL.Text = gLAccountPosting[0].GL_DAY1_FV_LOSS_PL_CODE;
            txtGL_DAY1_ADJ_FV_BS.Text = gLAccountPosting[0].GL_DAY1_ADJ_FV_BS_CODE;
            txtGL_WOFF_INT_DISC_LN.Text = gLAccountPosting[0].GL_WOFF_INT_DISC_LN_CODE;
            txtGL_DAY1_DEF_EXP_STAFF_BS.Text = gLAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_CODE;
            txtGL_AMC_EMP_CST_PL.Text = gLAccountPosting[0].GL_AMC_EMP_CST_PL_CODE;
            txtGL_AMC_DEF_EXP_STAFF_BS.Text = gLAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_CODE;
            txtGL_SUBSIDY_INT_REC_BS.Text = gLAccountPosting[0].GL_SUBSIDY_INT_REC_BS_CODE;
            txtGL_SUBSIDY_INT_INC_PL.Text = gLAccountPosting[0].GL_SUBSIDY_INT_INC_PL_CODE;
            txtGL_ACC_SUBSIDY_REV_CHG.Text = gLAccountPosting[0].GL_ACC_SUBSIDY_REV_CHG_CODE;
            txtGL_ADJ_SUBSIDY_REV_CHG.Text = gLAccountPosting[0].GL_ADJ_SUBSIDY_REV_CHG_CODE;
            #endregion

            #region 'Binging NAME Value'
            txtGL_ACCOUNT_NAME.Text = gLAccountPosting[0].GLAccount_NAME;
            txtGL_ADJ_INT_INC_PL_NAME.Text = gLAccountPosting[0].GL_ADJ_INT_INC_PL_NAME;
            txtGL_ADJ_FV_BS_NAME.Text = gLAccountPosting[0].GL_ADJ_FV_BS_NAME;
            txtGL_ADJ_INT_INC_ELCLS_PL_NAME.Text = gLAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_NAME;
            txtGL_ADJ_CST_BS_NAME.Text = gLAccountPosting[0].GL_ADJ_CST_BS_NAME;
            txtGL_REV_CST_PL_NAME.Text = gLAccountPosting[0].GL_REV_CST_PL_NAME;
            txtGL_ADJ_FEE_BS_NAME.Text = gLAccountPosting[0].GL_ADJ_FEE_BS_NAME;
            txtGL_REV_FEE_PL_NAME.Text = gLAccountPosting[0].GL_REV_FEE_PL_NAME;
            txtGL_SUBSEQ_ADJ_CST_BS_NAME.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_NAME;
            txtGL_SUBSEQ_ADJ_FEE_BS_NAME.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_NAME;
            txtGL_IMP_LOSS_PL_NAME.Text = gLAccountPosting[0].GL_IMP_LOSS_PL_NAME;
            txtGL_ALLW_BAD_DEBT_PL_NAME.Text = gLAccountPosting[0].GL_ALLW_BAD_DEBT_PL_NAME;
            txtGL_WOFF_ADJ_FV_BS_NAME.Text = gLAccountPosting[0].GL_WOFF_ADJ_FV_BS_NAME;
            txtGL_WOFF_ADJ_FEE_BS_NAME.Text = gLAccountPosting[0].GL_WOFF_ADJ_FEE_BS_NAME;
            txtGL_WOFF_ADJ_CST_BS_NAME.Text = gLAccountPosting[0].GL_WOFF_ADJ_CST_BS_NAME;
            txtGL_DAY1_FV_LOSS_PL_NAME.Text = gLAccountPosting[0].GL_DAY1_FV_LOSS_PL_NAME;
            txtGL_DAY1_ADJ_FV_BS_NAME.Text = gLAccountPosting[0].GL_DAY1_ADJ_FV_BS_NAME;
            txtGL_WOFF_INT_DISC_LN_NAME.Text = gLAccountPosting[0].GL_WOFF_INT_DISC_LN_NAME;
            txtGL_DAY1_DEF_EXP_STAFF_BS_NAME.Text = gLAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_NAME;
            txtGL_AMC_EMP_CST_PL_NAME.Text = gLAccountPosting[0].GL_AMC_EMP_CST_PL_NAME;
            txtGL_AMC_DEF_EXP_STAFF_BS_NAME.Text = gLAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_NAME;
            txtGL_SUBSIDY_INT_REC_BS_NAME.Text = gLAccountPosting[0].GL_SUBSIDY_INT_REC_BS_NAME;
            txtGL_SUBSIDY_INT_INC_PL_NAME.Text = gLAccountPosting[0].GL_SUBSIDY_INT_INC_PL_NAME;
            txtGL_ACC_SUBSIDY_REV_CHG_NAME.Text = gLAccountPosting[0].GL_ACC_SUBSIDY_REV_CHG_NAME;
            txtGL_ADJ_SUBSIDY_REV_CHG_NAME.Text = gLAccountPosting[0].GL_ADJ_SUBSIDY_REV_CHG_NAME;
            #endregion

        }
    }    
    private void SetControl()
    {
        SetControlReadOnly(form_control);
    }
    protected void SetControlReadOnly(PlaceHolder plcReadOnly)
    {
        foreach (Control ctrl in plcReadOnly.Controls)
        {
            if (ctrl is Button)
            {
                ((Button)ctrl).Enabled = false;
            }
            if (ctrl is TextBox)
            {
                ((TextBox)ctrl).Attributes["readOnly"] = "true";
                ((TextBox)ctrl).BackColor = System.Drawing.Color.FromArgb(224, 224, 224);
            }
            else if (ctrl is DropDownList)
            {
                ((DropDownList)ctrl).Enabled = false;
                ((DropDownList)ctrl).BackColor = System.Drawing.Color.FromArgb(224, 224, 224);
            }
            else if (ctrl is RadioButton)
            {
                ((RadioButton)ctrl).Attributes["readOnly"] = "true";
                ((RadioButton)ctrl).BackColor = System.Drawing.Color.FromArgb(224, 224, 224);
            }
            else if (ctrl is Image)
            {
                ((Image)ctrl).Attributes["disabled"] = "true";
            }
        }
    }
    private void ViewMenu()
    {
        MenuTitleBar = Resources.ifrsMenu.WIN31_GL_TR_3V;
    }
    #endregion
}